const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    const content = [];
    for(let i = 0; i < 100; i++)
        content.push({
            id: `2019${i}`,
            code: `2019${i}`,
            name: `大区${i}`,
            brandCode: `00${i}`,
            brandName: `品牌${i}`,
            branchCode: '20119',
            areaName: 'AreaName',
            address: 'Address',
            email: 'Email',
            remark: 'remark',
            status: 1,
            rowVersion: 'string',
            options: ['update', 'abandon']
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});

router.put('/:id', (req, res) => {
    res.json(
        {
            message: '修改成功'
        }
    );
});

router.post('/', (req, res) => {
    res.json(
        {
            message: '提交成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

router.get('/forSubDealer', (req, res) => {
    const content = [];
    for(let i = 0; i < 100; i++)
        content.push({
            id: `2019${i}`,
            code: `2019${i}`,
            name: `大区${i}`,
            isLeaf: true
        });
    res.json({
        message: '',
        payload: {
            content,
        }
    });
});

router.get('/forDealer/:id', (req, res) => {
    res.json(
        {
            message: 'string',
            payload: {
                id: '20191',
                code: '20191',
                name: '大区1',
                branchName: 'X公司',
                branchCode: '513123',
                rowVersion: 'string',
                dealers: [
                    {
                        id: '20191',
                        code: 'A1子公司',
                        name: 'A1子公司'
                    },
                    {
                        id: '20192',
                        code: 'A2子公司',
                        name: 'A2子公司'
                    }]
                
            }
        }
    );
});

router.put('/forDealer/:id', (req, res) => {
    res.json(
        {
            message: '成功'
        }
    );
});

router.get('/:id', (req, res) => {
    res.json(
        {
            message: 'string',
            payload: {
                id: '20191',
                code: '20191',
                name: '大区x',
                brandName: 'X品牌',
                brandCode: '品牌x',
                regionId: '1',
                areaName: '东南亚',
                address: 'Address',
                email: 'Email',
                remark: 'Remark',
                rowVersion: 'string',
                options: ['update', 'abandon']
            }
        }
    );
});
module.exports = router;
